package com.sfac.javaEE.util;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileCopyUtil {

    public static void main(String[] args) throws IOException {
        //创建一个FileInputStream对象(源文件路径)
        FileInputStream in = new FileInputStream("D:\\a\\1.jpg");

        //创建一个FileOutputStream对象(目标路径)
        FileOutputStream out = new FileOutputStream("D:\\b\\1.jpg");

        //进行复制操作
        int len = 0;
        byte[] byts = new byte[1024];
        while ((len = in.read(byts)) != -1) {
            //注意：字节流会直接写入到文件当中，不用刷新缓存
            out.write(byts, 0, len);
        }

        //释放资源
        in.close();
        out.close();
    }
}